<template>
  <div class="login-container">
    <div class="login-box">
      <SwitchDark class="login-dark" />
      <div class="login-left">
        <img src="@/assets/image/login/side-logo.png" />
      </div>
      <div class="login-form">
        <LoginForm v-if="accountLogin" />
        <LoginQrcode v-else />
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import LoginForm from './components/LoginForm.vue'
  import SwitchDark from '@/components/SwitchDark/index.vue'
  import LoginQrcode from './components/LoginQrcode.vue'
  import { getCode } from './ddtalk'
  const accountLogin = ref<boolean>(true)
  import * as dd from 'dingtalk-jsapi'
  const handleClick = () => {
    console.log('=======', accountLogin)
    accountLogin.value = !accountLogin.value
  }
  onMounted(() => {
    console.log(dd)
    if (dd.env.platform !== 'notInDingTalk') {
      dd.ready(() => {
        //使用SDK 获取免登授权码
        dd.runtime.permission.requestAuthCode({
          corpId: 'ding7851c59326b171d1',
          onSuccess: (info: any) => {
            //获取登录所需信息
            console.log(info)
          },
          onFail: (err: any) => {
            alert('fail')
            alert(JSON.stringify(err))
          },
        })
      })
    }
  })
</script>
<style lang="scss" scoped>
  @import './index';
</style>
